binder: Make a client SecurityPolicy test simpler and more realistic#12825
Open
jdcormie wants to merge 3 commits into
Open
binder: Make a client SecurityPolicy test simpler and more realistic#12825jdcormie wants to merge 3 commits into
jdcormie wants to merge 3 commits into
Conversation
Makes it easier to add new arguments with defaults in the future. TAG=agy CONV=e849839d-3cdc-4bcc-863d-9c8b6d2f47f6
LeakSafeOneWayBinder.Decorator lets us intercept Binder transactions on the receiving side for testing. Unlike the existing OneWayBinderProxy Decorator (works on the sending side), this lets a test inject code on the same thread that calls onTransact(). We'll use this in a follow up commit to simulate the UID of the caller. TAG=agy CONV=e849839d-3cdc-4bcc-863d-9c8b6d2f47f6
Add UID faking decorators using the new test support plumbing. This allow tests to configure fake UIDs for the client and server just once during the "arrange" phase. Use this new test infra to simplify a RobolectricBinderTransportTest auth test. TAG=agy CONV=e849839d-3cdc-4bcc-863d-9c8b6d2f47f6
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Binder transport test infrastructure (especially under Robolectric) to make client SecurityPolicy authorization tests more realistic by simulating Binder calling-UID propagation in same-process Robolectric runs, and introduces a general “inbound binder decorator” hook to support that simulation.
Changes:
- Add Robolectric-only helpers to pass/restore a fake calling UID via the transaction
Parcel. - Add
LeakSafeOneWayBinder.Decoratorand plumb an inbound-transaction decorator throughBinderTransportand the client transport factory. - Refactor
BinderServerTransportconstruction to aBuilderand simplify a Robolectric test accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| binder/src/test/java/io/grpc/binder/internal/RobolectricUidPropagation.java | New Robolectric test helper to prepend UID on outgoing transactions and restore it on incoming handling. |
| binder/src/test/java/io/grpc/binder/internal/RobolectricBinderTransportTest.java | Update test to use UID propagation decorators instead of global ShadowBinder manipulation. |
| binder/src/test/java/io/grpc/binder/internal/BinderServerTransportTest.java | Switch test helper from a local builder wrapper to BinderServerTransport.Builder. |
| binder/src/main/java/io/grpc/binder/internal/LeakSafeOneWayBinder.java | Add Decorator interface and identity decorator for transaction handler decoration. |
| binder/src/main/java/io/grpc/binder/internal/BinderTransport.java | Accept/apply an inbound binder decorator when constructing the incoming LeakSafeOneWayBinder. |
| binder/src/main/java/io/grpc/binder/internal/BinderServerTransport.java | Replace static factory with Builder, and plumb inbound binder decorator into transport construction. |
| binder/src/main/java/io/grpc/binder/internal/BinderServer.java | Update server-side transport creation to use BinderServerTransport.Builder. |
| binder/src/main/java/io/grpc/binder/internal/BinderClientTransportFactory.java | Add/configure inboundBinderDecorator on the client transport factory builder. |
| binder/src/main/java/io/grpc/binder/internal/BinderClientTransport.java | Pass the factory’s inbound binder decorator through to the base BinderTransport. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.